package com.crm.pojo;


import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.GenericGenerator;
@Entity
@Table(name="t_user")
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
public class User {
	private String id;
	private String userName;
	private String password;
	private String pic;
	private Group group;
	//one to many
	private Set<Deal> dealSet;
	private Set<Dealnote> dealnoteSet;
	private Set<Contact> contactSet;
	
	
	@Id
	@GenericGenerator(name="idGenerator" , strategy="uuid")
	@GeneratedValue(generator="idGenerator")
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getPic() {
		return pic;
	}
	public void setPic(String pic) {
		this.pic = pic;
	}
	
	@ManyToOne(fetch=FetchType.EAGER,cascade=CascadeType.REMOVE)
	@JoinColumn(name="groupId")
	public Group getGroup() {
		return group;
	}
	public void setGroup(Group group) {
		this.group = group;
	}
	
	@OneToMany(mappedBy="user")
	public Set<Deal> getDealSet() {
		return dealSet;
	}
	public void setDealSet(Set<Deal> dealSet) {
		this.dealSet = dealSet;
	}
	
	@OneToMany(mappedBy="user")
	public Set<Dealnote> getDealnoteSet() {
		return dealnoteSet;
	}
	public void setDealnoteSet(Set<Dealnote> dealnoteSet) {
		this.dealnoteSet = dealnoteSet;
	}
	@OneToMany(mappedBy="user")
	public Set<Contact> getContactSet() {
		return contactSet;
	}
	public void setContactSet(Set<Contact> contactSet) {
		this.contactSet = contactSet;
	}
	
	
	
}
